package com.acme.bankapp.domain;
import java.util.LinkedList;
import java.util.List;

import com.acme.bankapp.domain.Client;

public class Bank {
	private List<Client> clients;
	public Bank() {
		this.clients = new LinkedList<Client>();
	}
	public void printAllClients() {
		for (Client client: clients) {
			System.out.println(client.getGender().getSalutation()+" "+client.getFirstName()+" "+client.getLastName());
		}
	}
	public void printBalance() {
		for (Client client: clients) {
			System.out.println(client.getAccount().getBalance());
		}
	}
	public void addClient(Client client) {
		if ((client != null)&&(clients.contains(client) != true)) {
			clients.add(client);
		}
	}
	public void withdrawClient(Client client, double x) {
		if (client != null) {
			client.getAccount().withdraw(x);
		}
	}
	public void depositeClient(Client client, double x) {
		if (client != null) {
			client.getAccount().deposite(x);
		}
	}
	public void printClient(Client client) {
		if (client != null) {
			System.out.println(client.getGender().getSalutation()+" "+client.getFirstName()+" "+client.getLastName()+" "+client.getAccount().getBalance()+" "+client.getAccount().maxCredit());
		}
	}
	public Client searchClient(String searchFirstName, String searchLastName) {
		for (Client client: clients) {
			final String firstName = client.getFirstName();
			final String lastName = client.getLastName();
			if ((firstName.equals(searchFirstName))&&(lastName.equals(searchLastName))) {
				return client;
			}
		}
		return null;
	}
}
